﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WorldView;
using System.Windows.Forms;
using System.Threading;
using CommandLine;
using System.IO;

namespace TerrariaWorldViewerCmd
{
    class Program
    {
        static void Main(string[] args)
        {
            var options = new Options();            
            var settings = new CommandLineParserSettings();
            settings.CaseSensitive = false;
            settings.HelpWriter = Console.Error;
            ICommandLineParser optionsParser = new CommandLineParser(settings);
            
            if (optionsParser.ParseArguments(args, options))
            {
                if (!File.Exists(options.SourceWorld))
                {
                    Console.WriteLine("The specified source world file doesn't exist");
                    Environment.Exit(2);
                }

                var worldMapper = new CommandLineWorldMapper();
                worldMapper.GenerateWorld(options);
            }
            else
                Environment.Exit(1);

            Environment.Exit(0);
        }
    }
}
